#include <algorithm>
#include <cstdio>

using namespace std;

typedef long long ll;
const int maxn = 18, mods = 1000000007;
int n, k, a[maxn + 1];

ll inc(ll &a, ll b) { return a = (a + b) % mods; }
ll f[1 << maxn][2 * maxn + 2], g[1 << maxn][2 * maxn + 2];

void solve() {
    for (int i = 1; i <= n; i++) {
        f[1 << (i - 1)][2*i] = 1;
    }

    for (int i = 0; i < (1 << n); i++) {
        for (int j = 2; j<=2*n+1; j++) {
            if (f[i][j]) {
                int nowa = a[j/2]+j%2;
                for (int x = 1; x <= n; x++) {
                    if (!((i >> (x - 1)) & 1)) {
                        int na = nowa==a[x] ? nowa+1 : max(nowa, a[x]), ns=i|(1<<(x-1)),
                            tar = nowa==a[x] ? 2*x+1 : (nowa>a[x] ? j : 2*x);
                        inc(f[ns][tar], f[i][j]);
                        inc(g[ns][tar], (g[i][j] + f[i][j] * k % mods * na % mods) % mods);
                    }
                }
            }
        }
    }

    int s = (1 << n) - 1, ans=0;
    ll ansf=0, ansg=0;
    for (int i = 2 * n + 1; i > 1; i--) {
        if (f[s][i]) {
            if (a[i/2]+i%2>ans) ans=a[i/2]+i%2, ansf=ansg=0;
            if (a[i/2]+i%2==ans) inc(ansf, f[s][i]), inc(ansg, g[s][i]);
        }
    }
    ll sum = 0, temp = 0;
    for (int i = 1; i < n; i++) {
        inc(sum, ansf * temp % mods);
        temp = (temp * 2 + 1) % mods;
    }
    printf("%d %lld\n", ans, (ansg+sum) % mods);
}

int main() {
    freopen("repair.in", "r", stdin);
    freopen("repair.out", "w", stdout);

    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%d", a + i);
    }
    solve();

    fclose(stdin);
    fclose(stdout);
    return 0;
}
